package com.weipai.education.config.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 所有写的拦截器，必须要在这个类里面注册，否则没用
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private LoginHandlerInterceptor loginHandlerInterceptor;
    
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        
        //请求用时拦截器
        registry.addInterceptor(new ExcuteTimeInterceptor());
        
        //登录拦截
        registry.addInterceptor(loginHandlerInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/login/login")
                .excludePathPatterns("/img/uploadingImg");
        
    }
}
